var 自动完成任务 = [
    [25971, "星之力强化"],
    [25971, "星之力强化"]
];
var 自动补充物品 = [2120000,2430865,2432022,2436226];
var status = 0;
var 箭头特效 = "#fUI/UIWindow.img/Quest/icon2/0#";

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(c, f, h) {
    var g = cm.getConstantScriptContent("菜单_NPC立绘");
    var d = Math.floor(Math.random() * g.length);
    var a = g[d][0];
    var e = randomNum(0, g[d][1]);
    cm.getPlayer().checkInnerSkill();
    for (var j in 自动补充物品) {
		if(j!==0 && cm.getPlayer().getItemQuantity(自动补充物品[j]) < 1){
		
			cm.gainItem(自动补充物品[j], 1);
			cm.playerMessage(-1, "已补充小礼物！")
		}else{
			if (j==0 && cm.getPlayer().getItemQuantity(自动补充物品[j]) < 1000) {
				cm.playerMessage(-1, " 『" + cm.getItemName(自动补充物品[j]) + "』 剩余:" + cm.getItemQuantity(自动补充物品[j]) + " 补充:" + (1000 - cm.getItemQuantity(自动补充物品[j])) + "");
				cm.gainItem(自动补充物品[j], 1000 - cm.getItemQuantity(自动补充物品[j]))
			}
        }
    }
    for (var b = 0; b < 自动完成任务.length; b++) {
        if (!cm.isQuestFinished(自动完成任务[b][0])) {
            cm.forceCompleteQuest(自动完成任务[b][0])
        }
    }
    if (cm.isQuestFinished(3506)) {
        cm.forceCompleteQuest(3507)
    }
    if (cm.isQuestFinished(3551)) {
        cm.forceCompleteQuest(3552)
    }
    if (cm.isQuestFinished(3513)) {
        cm.forceCompleteQuest(3514)
    }
    if (cm.isQuestFinished(3517)) {
        cm.forceCompleteQuest(3546);
        cm.forceCompleteQuest(3547)
    }
    if (status == 0 && c == 0) {
        cm.dispose();
        return
    }
    if (c == 1) {
        status++
    } else {
        status--
    }
    if (status == 0) {
        var k = " #face" + e + "##fs18##r#fn微软雅黑#欢迎使用 " + cm.getServerName() + " 至尊版菜单！#fs15#\r\n";
        k += "  #L100#" + 箭头特效 + "账户信息#l "+" #L101#" + 箭头特效 + "掉落查询#l#r  #L501#" + 箭头特效 + "剧情任务#l  #L30#" + 箭头特效 + "GM功能#l \r\n#k#b";
        k += "  #L2#" + 箭头特效 + "万能传送#l";
        k += "  #L8#" + 箭头特效 + "" + (cm.isQuestFinished(1465) ? "五转中心#l" : "快速转职#l") + "#l";
        k += "  #L16#" + 箭头特效 + "杂货商店#l";
        k += "  #L21#" + 箭头特效 + "回到自由#l\r\n";
        
        k += "  #L10#" + 箭头特效 + "在线奖励#l";
        k += "  #L0#" + 箭头特效 + "等级奖励#l";
		k += "  #L12#" + 箭头特效 + "充值礼包#l";
        k += "  #L11#" + 箭头特效 + "怪怪系统#l\r\n";
        k += "  #L77#" + 箭头特效 + "在线商城#l";
        k += "  #L4#" + 箭头特效 + "国服商城#l";
        k += "  #L7#" + 箭头特效 + "美容美发#l";
        
        k += "  #L200#" + 箭头特效 + "AI玩家#l\r\n";
        k += "  #L202##k" + 箭头特效 + "任务读档#l";
		k += "  #L204#" + 箭头特效 + "学习技能#l";
		k += "  #L9#" + 箭头特效 + "更多功能1#l";
        k += "#L203#" + 箭头特效 + "更多功能2#l\r\n#k#b";
		
		
        cm.askMenu_Bottom(k, 204, a)
    } else {
        if (status == 1) {
            switch (h) {
				case 204:
					cm.dispose();
                    cm.openNpc(9110002, "技能管理_通用");
                    break;
                case 203:
                    cm.dispose();
                    cm.openNpc(9310070, "更多服务_黄金版");
                    break;
                case 202:
                    cm.dispose();
                    cm.openNpc(9110002, "任务读档_至尊版");
                    break;
                case 101:
                    cm.dispose();
                    cm.openNpc(9110002, "BMS_单机攻略");
                    break;
                case 501:
                    cm.dispose();
                    cm.openNpc(1092017, "剧情任务");
                    break;
                case 500:
                    cm.dispose();
                    if (cm.getPlayer().getQuestStatus(33120) == 0) {
                        cm.forceStartQuest(33120)
                    }
                    cm.openUI(1103);
                    break;
                case 0:
                    cm.dispose();
                    cm.openNpc(1092017, "等级奖励_至尊版");
                    break;
                case 2:
                    cm.dispose();
                    cm.openNpc(2023000, "万能传送_至尊版");
                    break;
                case 4:
                    cm.dispose();
                    cm.enter商城();
                    break;
                case 7:
                    cm.dispose();
                    cm.openNpc(9390213, "美容美发_通用");
                    break;
                case 77:
                    cm.dispose();
                    cm.openNpc(9110002, "新购物中心_至尊版");
                    break;
                case 8:
                    cm.dispose();
                    cm.openNpc(9010047, "快速转职_通用");
                    break;
                case 9:
                    cm.dispose();
                    cm.openNpc(9310476, "所有功能_至尊版");
                    break;
                case 10:
                    cm.dispose();
                    cm.openNpc(9400940, "在线奖励_至尊版");
                    break;
                case 11:
                    cm.dispose();
                    cm.openUI(596);
                    break;
                case 12:
                    cm.dispose();
                    cm.openNpc(9100000, "首充礼包_至尊版");
                    break;
                case 16:
                    cm.dispose();
                    cm.openNpc(3003100, "杂货店_至尊版");
                    break;
                case 21:
                    if (eim == null) {
                        if (cm.getMapId() == 910000000) {
                            cm.dispose();
                            cm.sendOk("您已经在自由市场了。")
                        } else {
                            cm.dispose();
                            cm.warp(910000000, 0)
                        }
                    } else {
                        cm.dispose();
                        cm.getTopMsgFont("这里无法进行传送", 3, 20, 4, 0, 0)
                    }
                    break;
                case 100:
                    cm.dispose();
                    cm.openNpc(9310362, "个人信息_至尊版");
                    break;
                case 30:
                    cm.dispose();
                    cm.openNpc(9110002, "快捷功能_通用");
                    break;
                case 200:
                    cm.dispose();
                    cm.openNpc(9110002, "模拟召唤玩家");
                    break;
                default:
                    cm.sendOk("该功能正在紧张进行制作中，请耐心等待。");
                    cm.dispose();
                    break
            }
        }
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
};